package com.wyh.day05.exercises;

/**
 * @author 王艺豪
 * @version 1.0
 */
public class Exercise03 {
    public static void main(String[] args) {

        //选择排序
        int[] a = {3, 2, 4, 5, 6, 43, 6, 1};
        System.out.println("选择排序");
        for (int i = 0; i < a.length - 1; i++) {
            for (int j = i; j < a.length; j++) {
                if (a[j] < a[i]) {
                    int tmp = a[j];
                    a[j] = a[i];
                    a[i] = tmp;
                }
            }

            System.out.println("第" + (i + 1) + "次排序");
            for (int j = 0; j < a.length; j++) {
                System.out.print(a[j] + " ");
            }
            System.out.println();
        }

        System.out.println("排序后的效果");
        for (int i : a) {
            System.out.print(i + " ");
        }
    }
}
